package com.tydic.workflow.listener;

import com.tydic.common.core.enums.UserTypeEnum;
import com.tydic.common.core.utils.SpringUtils;
import com.tydic.system.domain.SysUser;
import com.tydic.system.service.ISysUserService;
import org.flowable.task.service.delegate.DelegateTask;
import org.flowable.task.service.delegate.TaskListener;

import java.util.Set;
import java.util.stream.Collectors;

/**
 * 待结算监听器
 */
public class SettleAccountUserTaskListener implements TaskListener {
    @Override
    public void notify(DelegateTask delegateTask) {
        ISysUserService userService = SpringUtils.getBean(ISysUserService.class);
        Set<String> userCodes = userService.getUsersByUserTypes(UserTypeEnum.PLATFORM.getUserType()).stream().map(SysUser::getUserCode).collect(Collectors.toSet());
        delegateTask.addCandidateUsers(userCodes);
    }
}
